[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 kbhit()                 Check Keyboard Input Buffer for Character Waiting

 #include   <conio.h>

 int        kbhit(void);

    kbhit() checks the console for a recent keypress.  If there has been
    one, the character is waiting in the input buffer and can be read
    with getch() or getche().

       Returns:     Nonzero if a key has been pressed; 0, if not.

         Notes:     If getch() or getche() is called to read a key, but
                    kbhit() is not called first to check whether a
                    character is waiting in the buffer, the program may
                    pause until a key is pressed.

   -------------------------------- Example ---------------------------------

    The following statements check whether a key has been pressed before
    they read a character from the console.

           #include <conio.h>

           int keypress, ch;

           main()
           {
               keypress = kbhit();
               if (keypress != 0)
                  ch = getche();
           }


See Also: getch() getche()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson